import os

import PIL.Image as Image

path_data = r'D:\allworks\gbl\data\publicSentiment\2099'
name_error = []

for name_file in os.listdir(path_data):
    if 'jpg' in name_file:
        try:
            Image.open(os.path.join(path_data, name_file)).convert('RGB')
        except Exception:
            name_error.append(name_file)

print(name_error)

